//
//  XYAddPhotoCollectionCell.m
//  Zhihuijinfu
//
//  Created by XY Lv on 17/3/22.
//  Copyright © 2017年 王笛. All rights reserved.
//

#import "XYAddPhotoCollectionCell.h"

@implementation XYAddPhotoCollectionCell

- (instancetype)initWithFrame:(CGRect)frame{
    self  = [super initWithFrame:frame];
    if(self){
        self.xyCellMode = XYCellModeBrowser;
        [self xyLayoutImgViewWithFrame:frame];
    }
    return self;
}

- (void)xyLayoutImgViewWithFrame:(CGRect)frame{
    self.xyImgView = [[UIImageView alloc]initWithFrame:CGRectMake(0, 0, frame.size.width, frame.size.height)];
    [self addSubview:self.xyImgView];
    [self.xyImgView setImage:[UIImage imageNamed:@"xy_icon_addPhoto"]];
    self.xyImgView.userInteractionEnabled = YES;
    
    CGFloat selectW = xy(17.5);
    self.xySelectImgView = [[UIImageView alloc]initWithFrame:CGRectMake(CGRectGetWidth(self.xyImgView.frame) - selectW, 0, selectW, selectW)];
    [self.xyImgView addSubview:self.xySelectImgView];
    [self.xySelectImgView setImage:[UIImage imageNamed:@"photo_slected"]];
    self.xySelectImgView.hidden = YES;
    
    UILongPressGestureRecognizer * longTap = [[UILongPressGestureRecognizer alloc]initWithTarget:self action:@selector(xyLongTap:)];
    [self.xyImgView addGestureRecognizer:longTap];
    
}

//事件
- (void)xyLongTap:(UILongPressGestureRecognizer *)tap{
    if(self.xyDelegate&&[self.xyDelegate respondsToSelector:@selector(xyPhotoCellLongTap:withCell:)]){
        
        [self.xyDelegate xyPhotoCellLongTap:tap withCell:self];

    }
}


- (void)setXyIsChecked:(bool)xyIsChecked{
    _xyIsChecked = xyIsChecked;
    if(xyIsChecked){
        self.xySelectImgView.hidden = NO;
    }else{
        self.xySelectImgView.hidden = YES;

    }
}


@end








